<template>
    <el-select :value="value+''" @input="$emit('input', $event)" :placeholder="placeholder" filterable remote reserve-keyword clearable>
        <el-option :label="data.username" v-for="data in dataList" :key="data.id" :value ="data.username">{{data.username}}</el-option>
    </el-select>
</template>
<script>
export default {
  name: 'UserSelect',
  data () {
    return {
      dataList: []
    }
  },
  props: {
    value: [Number, String],
    dictType: String,
    placeholder: String
  },
  mounted () {
    this.getDataList()
  },
  created () {
    this.getDataList()
  },
  methods: {
    getDataList () {
      return this.$http.get('/sys/user/all').then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
        this.dataList = res.data
      }).catch(() => {})
    }
  }
}
</script>
